package com.wondersgroup.insurance.dnuilearn;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.wondersgroup.insurance.dnuilearn.viewgroups.tables.BaseTableAdapter;
import com.wondersgroup.insurance.dnuilearn.viewgroups.tables.TableView;
import com.wondersgroup.insurance.dnuilearn.views.canvas.RevealDrawable;
import com.wondersgroup.insurance.dnuilearn.views.shader.RadarView1;

public class MainActivity extends AppCompatActivity {

    RadarView1 radarView = null;

    RevealDrawable rd = null;
    ImageView image = null;

    int level = 1000;


    private int[] mImgIds = new int[] { //7个
            R.drawable.avft,
            R.drawable.box_stack,
            R.drawable.bubble_frame,
            R.drawable.bubbles,
            R.drawable.bullseye,
            R.drawable.circle_filled,
            R.drawable.circle_outline,

            R.drawable.avft,
            R.drawable.box_stack,
            R.drawable.bubble_frame,
            R.drawable.bubbles,
            R.drawable.bullseye,
            R.drawable.circle_filled,
            R.drawable.circle_outline
    };
    private int[] mImgIds_active = new int[] {
            R.drawable.avft_active, R.drawable.box_stack_active, R.drawable.bubble_frame_active,
            R.drawable.bubbles_active, R.drawable.bullseye_active, R.drawable.circle_filled_active,
            R.drawable.circle_outline_active,
            R.drawable.avft_active, R.drawable.box_stack_active, R.drawable.bubble_frame_active,
            R.drawable.bubbles_active, R.drawable.bullseye_active, R.drawable.circle_filled_active,
            R.drawable.circle_outline_active
    };

    public Drawable[] revealDrawables;

    LayoutInflater inflater;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        inflater = LayoutInflater.from(getApplicationContext());
        TableView tableView = (TableView) findViewById(R.id.table);
        tableView.setAdapter(new BaseTableAdapter() {
            @Override
            public int getRowCount() {
                return 20;
            }

            @Override
            public int getColmunCount() {
                return 5;
            }
            private int getLayout(int row, int column) {
                final int layoutResource;
                switch (getItemViewType(row, column)) {
                    case 0:
                        layoutResource = R.layout.item_table1_header;
                        break;
                    case 1:
                        layoutResource = R.layout.item_table1;
                        break;
                    default:
                        throw new RuntimeException("wtf?");
                }
                return layoutResource;
            }
            @Override
            public View getView(int row, int column, View convertView, ViewGroup parent) {
                if (convertView == null) {
                    convertView= inflater.inflate(getLayout(row,column),parent,false);
                }
                //
                TextView textView= (TextView) convertView.findViewById(R.id.text1);
                textView.setText("第 "+row+"行"+"  列 "+column);
                return convertView;
            }

            @Override
            public int getWidth(int column) {
                return 200;
            }

            @Override
            public int getHeight(int row) {
                return 80;
            }

            @Override
            public int getItemViewType(int row, int column) {
                if (row < 0) {
                    return 0;
                } else {
                    return 1;
                }
            }

            @Override
            public int getViewTypeCount() {
                return 2;
            }
        });
//        SearchView1 searchView = new SearchView1(this);
//        setContentView(searchView);
//        searchView.setState(SearchView.SearchState.END);
    }


//    radarView = (RadarView) findViewById(R.id.radar);
//    findViewById(R.id.start).setOnClickListener(new View.OnClickListener() {
//        @Override
//        public void onClick(View v) {
//            radarView.start();
//        }
//    });
//    findViewById(R.id.stop).setOnClickListener(new View.OnClickListener() {
//        @Override
//        public void onClick(View v) {
//            radarView.stop();
//        }
//    });



}
